CC = g++
CFLAGS = -g -I$(HOME)/include -lpthread

ALL =     bitmatrices.h    \
		  bitmatrices.cpp  \
		  reed_sol.h       \
		  reed_sol.cpp     \
		  jerasure.h       \
		  jer_matrix.cpp   \
		  galois.h         \
		  galois.cpp       \
		  jer_gen_t.cpp    \
		  jer_slices.cpp   \
		  galois_01      \
		  jerasure_01      \
		  jerasure_02      \
		  jerasure_03      \
		  jerasure_04      \
		  reed_sol_crs_01      \
		  reed_sol_crs_02      \
		  reed_sol_crs_03      \
		  reed_sol_rs_r6_02      \
		  reed_sol_rs_01      \
		  reed_sol_rs_02      \
		  reed_sol_rs_r6_01      \
		  reed_sol_crs_04        \
		  reed_sol_crs_05         \
		  reed_sol_crs_06         \
		  reed_sol_crs_07			\
		  bitmatrices_min_den_r6_01	\
		  bitmatrices_evenodd_01	\
		  bitmatrices_rdp_01	\
		  encoder			\
		  decoder			\
		  personal_retrieval \
		  personal_archiving \
		  raid

all: $(ALL)

clean:
	rm -f core *.o $(ALL) a.out

.SUFFIXES: .cpp .o
.cpp.o:
	$(CC) $(CFLAGS) -c $*.cpp

bitmatrices.h: ../bitmatrices.h
	rm -f bitmatrices.h ; cp ../bitmatrices.h . ; chmod 0444 bitmatrices.h

bitmatrices.cpp: ../bitmatrices.cpp
	rm -f bitmatrices.cpp ; cp ../bitmatrices.cpp . ; chmod 0444 bitmatrices.cpp

reed_sol.h: ../reed_sol.h
	rm -f reed_sol.h ; cp ../reed_sol.h . ; chmod 0444 reed_sol.h

reed_sol.cpp: ../reed_sol.cpp
	rm -f reed_sol.cpp ; cp ../reed_sol.cpp . ; chmod 0444 reed_sol.cpp

jerasure.h: ../jerasure.h
	rm -f jerasure.h ; cp ../jerasure.h . ; chmod 0444 jerasure.h

jer_matrix.cpp: ../jer_matrix.cpp
	rm -f jer_matrix.cpp ; cp ../jer_matrix.cpp . ; chmod 0444 jer_matrix.cpp

galois.h: ../galois.h
	rm -f galois.h ; cp ../galois.h . ; chmod 0444 galois.h

galois.cpp: ../galois.cpp
	rm -f galois.cpp ; cp ../galois.cpp . ; chmod 0444 galois.cpp

jer_gen_t.cpp: ../jer_gen_t.cpp
	rm -f jer_gen_t.cpp ; cp ../jer_gen_t.cpp . ; chmod 0444 jer_gen_t.cpp

jer_slices.cpp: ../jer_slices.cpp
	rm -f jer_slices.cpp ; cp ../jer_slices.cpp . ; chmod 0444 jer_slices.cpp

galois.o: galois.h
jer_gen_t.o: jerasure.h galois.h
jer_slices.o: jerasure.h galois.h
jer_matrix.o: jerasure.h galois.h
bitmatrices.o: jerasure.h galois.h bitmatrices.h
reed_sol.o: jerasure.h galois.h reed_sol.h

galois_01: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o galois_01.o
	$(CC) $(CFLAGS) -o galois_01 galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o galois_01.o

reed_sol_rs_01: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_rs_01.o
	$(CC) $(CFLAGS) -o reed_sol_rs_01 galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_rs_01.o

reed_sol_rs_02: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_rs_02.o
	$(CC) $(CFLAGS) -o reed_sol_rs_02 galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_rs_02.o

reed_sol_rs_r6_01: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_rs_r6_01.o
	$(CC) $(CFLAGS) -o reed_sol_rs_r6_01 galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_rs_r6_01.o

jerasure_01: galois.o jer_matrix.o jer_gen_t.o jer_slices.o jerasure_01.o
	$(CC) $(CFLAGS) -o jerasure_01 galois.o jer_matrix.o jer_gen_t.o jer_slices.o jerasure_01.o

jerasure_02: galois.o jer_matrix.o jer_gen_t.o jer_slices.o jerasure_02.o
	$(CC) $(CFLAGS) -o jerasure_02 galois.o jer_matrix.o jer_gen_t.o jer_slices.o jerasure_02.o

jerasure_03: galois.o jer_matrix.o jer_gen_t.o jer_slices.o jerasure_03.o
	$(CC) $(CFLAGS) -o jerasure_03 galois.o jer_matrix.o jer_gen_t.o jer_slices.o jerasure_03.o

jerasure_04: galois.o jer_matrix.o jer_gen_t.o jer_slices.o jerasure_04.o
	$(CC) $(CFLAGS) -o jerasure_04 galois.o jer_matrix.o jer_gen_t.o jer_slices.o jerasure_04.o

reed_sol_crs_01: galois.o reed_sol.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol_crs_01.o
	$(CC) $(CFLAGS) -o reed_sol_crs_01 reed_sol.o galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol_crs_01.o

reed_sol_crs_02: galois.o reed_sol.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol_crs_02.o
	$(CC) $(CFLAGS) -o reed_sol_crs_02 reed_sol.o galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol_crs_02.o

reed_sol_crs_03: galois.o reed_sol.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol_crs_03.o
	$(CC) $(CFLAGS) -o reed_sol_crs_03 reed_sol.o galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol_crs_03.o

reed_sol_rs_r6_02: galois.o reed_sol.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol_rs_r6_02.o
	$(CC) $(CFLAGS) -o reed_sol_rs_r6_02 reed_sol.o galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol_rs_r6_02.o

reed_sol_crs_04: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_crs_04.o
	$(CC) $(CFLAGS) -o reed_sol_crs_04 galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_crs_04.o

reed_sol_crs_05: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_crs_05.o
	$(CC) $(CFLAGS) -o reed_sol_crs_05 galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_crs_05.o

reed_sol_crs_06: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_crs_06.o
	$(CC) $(CFLAGS) -o reed_sol_crs_06 galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_crs_06.o

reed_sol_crs_07: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_crs_07.o
	$(CC) $(CFLAGS) -o reed_sol_crs_07 galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o reed_sol_crs_07.o

bitmatrices_min_den_r6_01: galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o bitmatrices_min_den_r6_01.o
	$(CC) $(CFLAGS) -o bitmatrices_min_den_r6_01 galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o bitmatrices_min_den_r6_01.o

test_evenodd_mds: galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o test_evenodd_mds.o
	$(CC) $(CFLAGS) -o test_evenodd_mds galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o test_evenodd_mds.o

bitmatrices_evenodd_01: galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o bitmatrices_evenodd_01.o
	$(CC) $(CFLAGS) -o bitmatrices_evenodd_01 galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o bitmatrices_evenodd_01.o

bitmatrices_rdp_01: galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o bitmatrices_rdp_01.o
	$(CC) $(CFLAGS) -o bitmatrices_rdp_01 galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o bitmatrices_rdp_01.o

encoder: reed_sol.o galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o encoder.o
	$(CC) $(CFLAGS) -o encoder galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o encoder.o reed_sol.o

decoder: reed_sol.o galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o decoder.o
	$(CC) $(CFLAGS) -o decoder galois.o jer_matrix.o jer_gen_t.o jer_slices.o bitmatrices.o decoder.o reed_sol.o

personal_retrieval: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o personal_retrieval.o
	$(CC) $(CFLAGS) -o personal_retrieval galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o personal_retrieval.o

personal_archiving: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o personal_archiving.o
	$(CC) $(CFLAGS) -o personal_archiving galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o personal_archiving.o

raid: galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o raid.o
	$(CC) $(CFLAGS) -o raid galois.o jer_matrix.o jer_gen_t.o jer_slices.o reed_sol.o raid.o
